package com.alon.spring01.study;

/**
 * @program: spring01
 * @description: 测试HashSet
 * @author: yulongguang
 * @create: 2019-05-04 21:35
 **/
public class HashName {

    private String first;
    private String last;


    public HashName(String first, String last) {
        this.first = first;
        this.last = last;
    }

    /**
     * 重写equals 方法
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o.getClass() == HashName.class) {
            HashName hashName = (HashName) o;
            return hashName.first.equals(first) && hashName.last.equals(last);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return first.hashCode();
    }

    @Override
    public String toString() {
        return "HashName{" +
                "first='" + first + '\'' +
                ", last='" + last + '\'' +
                '}';
    }
}
